/**
 * Copyright 2011 Adrian Witas
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.abstractmeta.commandify.command;

import org.abstractmeta.commandify.OwnerSelfCommandifyAccessor;
import org.abstractmeta.reflectify.Accessor;
import org.abstractmeta.reflectify.Reflectify;

/**
 * Represents Commands
 *
 * @author Adrian Witas
 */
public interface Commands<T> extends Iterable<Command<T>> {


    void associateOwnerSelfCommandAccessor(Object owner, Object source);

    void dissociateOwnerSelfCommandAccessor();

    /**
     * Gets this instance accessor form owner commandify
     * @return
     */
    OwnerSelfCommandifyAccessor<Object, T> getCommandifyAccessor();

    void setReflectify(Reflectify<T> reflectify);

    Reflectify<T> getReflectify();

    Accessor<T, Object> getAccessor(Object source);

    void setUniqueField(String fieldName);

    String getUniqueField();

    boolean contains(String source);

    void add(Command<T> command);

    Class<T> getOwnerType();

    ConstructorCommand<T> getConstructorCommand();

    void setConstructorCommand(ConstructorCommand<T> command);

    T apply();

    void apply(T instance);

    void apply(String source, T instance);

    int size();

    void clear();

}
